﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using NetFtp.Core.Login;
using NetFtp.Core.Utils;

public partial class NewUser : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["USER_LOGIN"] == null)
            Response.Redirect("Default.aspx");
    }
    protected void cmdOk_Click(object sender, EventArgs e)
    {
        UserList liste = new UserList();
        User user = new User(txtLogin.Text, txtMdp.Text);

        if (txtMdp.Text != txtMdpConf.Text)
        {
            lblErreur.Text = GetGlobalResourceObject("General", "MDPDifferents").ToString();
            lblErreur.Visible = true;
            return;
        }

        if (liste.SearchUser(txtLogin.Text) == true)
        {
            lblErreur.Text = GetGlobalResourceObject("General", "LoginExist").ToString();
            lblErreur.Visible = true;
            return;
        }

        liste.AddUser(user);

        Session["USER_LOGIN"] = txtLogin.Text;

        Response.Redirect("UserAccount.aspx");
    }
}
